(define (new-conjoin conjuncts frame-stream) 
   (if (empty-conjunction? conjuncts) 
       frame-stream 
       (merge (qeval (first-conjunct conjuncts) 
                     frame-stream) 
              (new-conjoin (rest-conjuncts conjuncts) 
                           frame-stream)))) 
 (define (merge s1 s2) 
   (cond ((stream-null? s1) s2) 
         ((stream-null? s2) s1) 
         (else
          (stream-flatmap (lambda (frame1)
                            (stream-flatmap (lambda (frame2) 
                                              (merge-frame frame1 frame2)) 
                                            s2))
                          s1)))) 
 (define (merge-frames f1 f2) 
   (cond ((null? f1) f2) 
         ((eq? 'failed f2) 'failed) 
         (else  
          (let ((p1 (binding-variable (car f1)))
                (p2 (binding-value (car f1))))
            (let ((extension (extend-if-possible p1 p2 f2))) 
              (merge-frames (cdr f1) extension))))))